package com.umeox.watch.moto.launcher.ui.help;

import android.content.Context;
import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

/**
 * Created by Rambo 2024/1/15
 * Describe:
 */
public class EnlargeLinearLayoutManager extends LinearLayoutManager {

    public EnlargeLinearLayoutManager(Context context) {
        super(context);
        setOrientation(HORIZONTAL);
        setReverseLayout(false);
    }

    @Override
    public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) {
        float d = 0f;
        float b = 0f;
        View view = findViewByPosition(findFirstVisibleItemPosition());
        if (view != null) {
            d = view.getPaddingTop() * 2f / view.getHeight();
            b = Math.abs(view.getX()) / view.getWidth();
            view.setScaleX(1 + d * (1 - b));
            view.setScaleY(1 + d * (1 - b));
//            TextView textView = view.findViewById(R.id.tv_number);
//            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX,64);
        }
        View view2;
        if (dx > 0) {
            view2 = findViewByPosition(findFirstVisibleItemPosition() + 1);
        } else {
            view2 = findViewByPosition(findFirstCompletelyVisibleItemPosition());
        }
        if (view2 != null) {
//            TextView textView = view2.findViewById(R.id.tv_number);
//            textView.setTextSize(TypedValue.COMPLEX_UNIT_PX,36);
            view2.setScaleX(1 + d * b);
            view2.setScaleY(1 + d * b);
        }
        return super.scrollHorizontallyBy(dx, recycler, state);
    }
}
